<template>
  <!-- <div> -->
  <el-dialog
    append-to-body
    title="导出凭证"
    :visible.sync="applyDialog"
    style="text-align:center;margin:0 auto;width:960px"
  >
    <el-form
      :model="reviewForm"
      :rules="rules"
      ref="reviewForm"
      style="text-align:center;margin:0 auto"
      size="mini"
      label-width="16%"
    >
      <el-row style="text-align:center;margin:0 auto">
        <el-col :span="24">
          <el-form-item label="时间：" prop="timeLimit">
            <el-date-picker
              v-model="reviewForm.timeLimit"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer">
      <el-button size="mini" @click="applyDialog = false">取消</el-button>
      <el-button
        size="mini"
        type="primary"
        @click="exportVoucherByMonth('reviewForm')"
        >导出</el-button
      >
    </div>
  </el-dialog>
  <!-- </div> -->
</template>
<script>
import { ajax } from "@/store/yg/common/utils";
import axios from "axios";
import * as constant from "@/store/yg/common/constant";

export default {
  props: ["row", "data", "more"],
  data() {
    return {
      reviewForm: {
        timeLimit: ""
      },
      rules: {
        timeLimit: [
          {
            type: "array",
            required: true,
            message: "请选择",
            trigger: "change"
          }
        ]
      },
      CurrencyTypeSource: {
        timeLimit: ""
      },
      applyDialog: false
    };
  },

  methods: {
    async exportVoucherByMonth() {
      if (!this.reviewForm.timeLimit) {
        this.$message.error("请选择时间");
        return;
      }
      console.log("this.reviewForm.timeLimit :>> ", this.reviewForm.timeLimit);
      var args = {};
      args["start"] = this.reviewForm.timeLimit[0];
      args["end"] = this.reviewForm.timeLimit[1];
      console.log("args", args);
      // return;
      let {code,data,message} = await ajax("exportVoucherByMonth", args);
      if(code === 200) {
        window.open(constant.FILE_SERVER + data)
      }else {
        this.$message.error(message || '系统错误')
      }

      this.applyDialog = false
    }
  },
  mounted() {
    this.applyDialog = true;
  }
};
</script>
<style scoped></style>

<style lang="scss">
// .row-item {
//   color: #3f4652;
//   line-height: 28px;
//   margin-bottom: 14px;
// }
</style>
